(function(vc){
    vc.extends({
        propTypes: {
           emitChooseDistributionMode:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseDistributionModeInfo:{
                distributionModes:[],
                _currentDistributionModeName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseDistributionMode','openChooseDistributionModeModel',function(_param){
                $('#chooseDistributionModeModel').modal('show');
                $that._refreshChooseDistributionModeInfo();
                $that._loadAllDistributionModeInfo(1,10,'');
            });
        },
        methods:{
            _loadAllDistributionModeInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        caId:vc.getCurrentCommunity().caId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('/distributionMode/queryDistributionMode',
                             param,
                             function(json){
                                var _distributionModeInfo = JSON.parse(json);
                                $that.chooseDistributionModeInfo.distributionModes = _distributionModeInfo.distributionModes;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseDistributionMode:function(_distributionMode){
                if(_distributionMode.hasOwnProperty('name')){
                     _distributionMode.distributionModeName = _distributionMode.name;
                }
                vc.emit($props.emitChooseDistributionMode,'chooseDistributionMode',_distributionMode);
                vc.emit($props.emitLoadData,'listDistributionModeData',{
                    distributionModeId:_distributionMode.distributionModeId
                });
                $('#chooseDistributionModeModel').modal('hide');
            },
            queryDistributionModes:function(){
                $that._loadAllDistributionModeInfo(1,10,$that.chooseDistributionModeInfo._currentDistributionModeName);
            },
            _refreshChooseDistributionModeInfo:function(){
                $that.chooseDistributionModeInfo._currentDistributionModeName = "";
            }
        }

    });
})(window.vc);
